/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */

package cn.com.ksplatform.modules.system.auth.dictmanager.service;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Repository;

import cn.com.ksplatform.base.service.BaseService;
import cn.com.ksplatform.modules.system.auth.dictmanager.model.PlatDictItem;
import net.sf.ehcache.CacheManager;

/**
 * @ClassName:PlatDictItemService <br/>
 * @deprecated:TODO. <br/>
 * @Date: 2015年5月25日 下午2:17:42 <br/>
 * 
 * @author Mr.Luoxing
 * @version 1.0
 */
@Repository("system.modules.system.PlatDictItemService")
public class PlatDictItemService extends BaseService {
	
	@Autowired
	@Qualifier("cacheManagerFactory")
	private CacheManager cacheManager;
	
	@Transactional
	@CachePut(value="DictCache",key="#entity.getItmeId()")
	public PlatDictItem save(PlatDictItem entity) {
		String id = entity.save();
		entity.setItmeId(id);
		return entity;
	}

	@Transactional
	@CachePut(value="DictCache",key="#entity.getItmeId()")
	public PlatDictItem update(PlatDictItem entity) {
		return entity.update();
	}

	@Transactional
	@CacheEvict(value="DictCache",key="#entity.getItmeId()")
	public PlatDictItem delete(PlatDictItem entity) {
		return entity.delete();
	}

	@Transactional
	@CachePut(value="DictCache",key="#entity.getItmeId()")
	public PlatDictItem saveOrUpdate(PlatDictItem entity) {
		return entity.saveOrUpdate();
	}

	@Transactional
	public List<PlatDictItem> getAllDictItem() {
		List<PlatDictItem> list = (List<PlatDictItem>) super.findAll("from "+PlatDictItem.class.getName());
		return list;
	}
}
